package 
{
	import flash.display.MovieClip;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	import flash.geom.Rectangle;
	import flash.system.Capabilities;
	import starling.core.*;
 
	public class Main extends MovieClip
	{
		private var st:Starling;
		
		public function Main()
		{
			stage.align = StageAlign.TOP_LEFT;
            stage.scaleMode = StageScaleMode.NO_SCALE;
			
			Starling.multitouchEnabled = true;
			Starling.handleLostContext = true;
			
			//Define the view port for the application
			var screenWidth:int  = stage.stageWidth;
			var screenHeight:int = stage.stageHeight;
			var viewPort:Rectangle = new Rectangle(0, 0, screenWidth, screenHeight)
			 
			st = new Starling(Controller, this.stage, viewPort);
			
			st.stage.stageWidth  = stage.stageWidth;
			st.stage.stageHeight = stage.stageHeight;
			
			//st.showStats = true;
			st.start();
			
			this.stage.addEventListener(Event.RESIZE, stageResized);
		}
		
		/**
		 * Handles resizing the interface, in case the event is fired after the main
		 * method executes.
		 */
		private function stageResized(e:Event):void
		{
			st.stage.stageWidth = this.stage.stageWidth;
			st.stage.stageHeight = this.stage.stageHeight;
			var viewPort:Rectangle = st.viewPort;
			viewPort.width = this.stage.stageWidth;
			viewPort.height = this.stage.stageHeight;
			st.viewPort = viewPort;
		}
	}
}